package com.fujin.gulimall.search.controller;

import com.fujin.gulimall.search.Vo.SearchParam;
import com.fujin.gulimall.search.Vo.SearchResult;
import com.fujin.gulimall.search.service.mallSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @title: searchController
 * @Author Tan
 * @Date: 2022/2/16 17:43
 * @Version 1.0
 */
@Controller
public class searchController {

    @Autowired
    private mallSearchService mallSearch;

    @GetMapping("/list.html")
    public String listPage(SearchParam searchParam, Model model, HttpServletRequest request){
        //通过HttpServletRequest 将请求的参数传入
        searchParam.set_queryString(request.getQueryString());

        SearchResult result = mallSearch.search(searchParam);

        model.addAttribute("result",result);

        return "list1";
    }

}
